#pragma once

#include <iostream>
#include "Mutex.hpp"
#include <pthread.h>

namespace CondMudule
{
    using namespace LockModule;
    class Cond
    {

    public:
        Cond()
        {
            int n = ::pthread_cond_init(&_cond, nullptr);
        }
        ~Cond()
        {
            int n = ::pthread_cond_destroy(&_cond);
        }

        void Wait(Mutex& mutex)
        {
            int n=::pthread_cond_wait(&_cond,mutex.LockPtr());
        }

        void Notify()
        {
            int n = ::pthread_cond_signal(&_cond);
        }

        void Notigyall()
        {
            int n = ::pthread_cond_broadcast(&_cond);
        }

    private:
        pthread_cond_t _cond;
    };
}